Android RecyclerView
Glossary of terms:
Adapter: A subclass of RecyclerView.Adapter responsible for providing views that represent items in a data set.
ok
Position: The position of a data item within an Adapter.
ok. adapter内のposition, それ以外のpositionないけど。
Index: The index of an attached child view as used in a call to getChildAt(int). Contrast with Position.
positionとずれるケースはあるのか?
Binding: The process of preparing a child view to display data corresponding to a position within the adapter.
adapterのデータを a child viewにつける
Recycle (view): A view previously used to display data for a specific adapter position may be placed in a cache for later reuse to display the same type of data again later. This can drastically improve performance by skipping initial layout inflation or construction.
adapterのpositionごとに viewそのものをcacheして再利用?
Scrap (view): A child view that has entered into a temporarily detached state during layout. Scrap views may be reused without becoming fully detached from the parent RecyclerView, either unmodified if no rebinding is required or modified by the adapter if the view was considered dirty.
現状で表示されずに、裏側にまわってる?view? 上記の recycleの運用上のために。
Dirty (view): A child view that must be rebound by the adapter before being displayed.
表示に回る前に、reboundが必要とされた(scrap?)view
Adapters
RecyclerView.Adapterは abstract classなので、自分で実装を書いて使う。
class MyAdapter(val MyList:ArrayList<Book>, val viewModel: MainViewModel): RecyclerView.Adapter<RecyclerView.ViewHolder>() {
containerViewを作る際の `LayoutInflater.from(context).inflate(int, ViewGroup, attachToRoot)のattachToRoot